package com.ocm.taglibs.standard.functions;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import net.sf.json.util.JSONUtils;

import com.ocm.core.exception.OCMRuntimeException;
import com.ocm.core.util.DateUtil;

public class Functions {

   @SuppressWarnings("rawtypes")
   public static boolean contains(List list, Object o) {
      if (list == null)
         return false;
      return list.contains(o);
   }

   public static String formatShortDate(Date value, int timezoneOffsetMinutes){
      try {
         if (value != null)
            return DateUtil.formatShortDate(value, timezoneOffsetMinutes);
         else 
            return "";
      }
      catch (ParseException e) {
         throw new OCMRuntimeException(e);
      }
   }

   public static boolean hasPermission(int accessMask, int permission) {
      boolean result = ((accessMask & permission) != 0);
      return result;
   }

   public static String parseJsonString(String value) {
      return JSONUtils.valueToString(value);
   }
}
